package com.schoolvisitors.enums;

import lombok.Getter;

@Getter
public enum GenderEnum {
    FEMALE((byte) 0, "女"),
    MALE((byte) 1, "男");

    private final byte code;
    private final String desc;

    GenderEnum(byte code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static GenderEnum fromCode(byte code) {
        for (GenderEnum gender : values()) {
            if (gender.getCode() == code) {
                return gender;
            }
        }
        throw new IllegalArgumentException("无效的性别代码: " + code);
    }
}
